package com.maintainence.demo.api;


import cn.hutool.core.date.DateTime;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


@Slf4j
@RestController
@RequestMapping("/test")
@Api(tags = "测试TestController正常功能")
public class TestController {

    public static final Map<String, Object> map = new ConcurrentHashMap<>();

    @GetMapping("time")
    @ApiOperation("time")
    public String time() {
        log.info("time: {}", DateTime.now());
        return DateTime.now().toString();
    }

    @GetMapping("testHeap")
    @ApiOperation("test the heap to make a demo")
    @SneakyThrows(Exception.class)
    public String testHeap() {
        for (int i = 0; i < 10000000; i++) {
            log.info("time: {}", DateTime.now());
            map.put(i + "", new Object());
        }
        return "ok";
    }

}
